package com.jiaz.controller;

import com.jiaz.entity.CheckIn;
import com.jiaz.mapper.CheckInMapper;
import com.jiaz.scripts.OriginFile;
import com.jiaz.service.CheckInService;
import com.jiaz.untils.ResponseBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

/**
 * @author jiajiazi
 * @version 1.0
 * @date 2022/4/21 23:36
 */
@Slf4j
@RestController
public class Index {

    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    @Autowired
    CheckInMapper checkInMapper;

    private String sigg = null;

    @Autowired
    private CheckInService checkInService;

    @RequestMapping("/index/sleep")
    public ResponseBean index() {
        log.info("Index-index122");
        if (sigg == null) {
            try {
                Thread.sleep(200);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            sigg = "";
        }

        return ResponseBean.error(200, "当前时间：" + simpleDateFormat.format(new Date()));
    }

    @RequestMapping("/unit/userDistantCount")
    public ResponseBean userDistantCount() {
        return ResponseBean.success(checkInService.userDistantCount());
    }
}
